package ubi.quando.App;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.osmdroid.util.GeoPoint;

public class EventPickUp extends EventBase
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	GeoPoint 						mPickUpLocation;
	String							mPULName;
	String							mPickerId;
	ArrayList<PickUpParticipant> 	mParticipants;
	
	public EventPickUp(GeoPoint dest, Date date, String creatorId, String pickerId, ArrayList<PickUpParticipant> participants) 
	{
		super(dest, date, creatorId);
		mParticipants = new ArrayList<PickUpParticipant>();
	
		if(participants != null)
		{
			for(PickUpParticipant c : participants)
			{
				mParticipants.add(c);
			}
		}
		
		mPickerId = pickerId;
	}
	
	protected void writeObject(ObjectOutputStream out) throws IOException
	{
		super.writeObject(out);
		out.writeObject(mPickUpLocation);
		out.writeObject(mPULName);
		out.writeObject(mPickerId);
		//TODO: Serialize participants
	}
	
	protected void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
	{
		super.readObject(in);
		Object temp = in.readObject();
	    if(temp != null)
	    {
	    	mPickUpLocation = (GeoPoint)temp;
	    }
		temp = in.readObject();
	    if(temp != null)
	    {
	    	mPULName = (String)temp;
	    }
		temp = in.readObject();
	    if(temp != null)
	    {
	    	mPickerId = (String)temp;
	    }
		//TODO: DeSerialize participants
	}
	
	public List<PickUpParticipant> getParticipants()
	{
		return mParticipants;
	}
	
	public GeoPoint GetPickUpLocation() {
		return mPickUpLocation;
	}

	public void SetPickUpLocation(GeoPoint loc) {
		mPickUpLocation = loc;
	}
	
	public void setmPULName(String PULName) {
		mPULName = PULName;
	}
	
	public String getmPULName() {
		return mPULName;
	}
	
	public String getPickerId() {
		return mPickerId;
	}

	@Override
	public EventType getType() {
		return EventType.PICK_ME_UP;
	}
}
